/*
 * Data.h
 *
 *  Created on: Dec 18, 2013
 *      Author: thanhkm chokki
 */

#ifndef DATA_H_
#define DATA_H_

//Declaration des bibliothéques necessaires pour le programme
#include <dirent.h>
#include <iostream>
#include <fstream>
#include <sstream>
#include <string.h>
#include <opencv2/opencv.hpp>
#include "opencv2/highgui/highgui.hpp"
#include "Utils.h"

using namespace std;
using namespace cv;

// Definition structure
typedef struct {
public:
	Mat image;
	string nomImage;
	int chiffreReel;
	int chiffreTrouve;
	vector<double> signature;
} classImage;

class Data {
public:
	Data();
	virtual ~Data();
	//function get data for training or testing
	// code = 1 get training data
	// code = 2 get testing data
	// code = 3 get validation data
	static vector<classImage> getData(int code);
	static vector<vector<vector<double>>> learning(int rows, int cols);

	// Fonctions implementees
	static void enregisterDescriptor(vector<vector<vector<double> > > vectDescript, string filename);
	static vector<vector<vector<double> > > recupDescriptor(string filename);
	static vector<string> split(string chaine, char check);


	// function for recognition
	static int getClass(vector<double> signature,
			vector<vector<vector<double>>> vectDes);
	static int recognizeKnn(vector<double> signature,
			vector<vector<vector<double> > > listNumberDescriptors, int k);
	static int recognizeNearest(vector<double> signature,
			vector<vector<vector<double> > > listNumberDescriptors, float threshold);

};

#endif /* DATA_H_ */
